package com.ys.erp.entity.data.bean;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * @author minamiyama
 * @date 2025/5/19 11:14
 *  首页聚合区的数据推荐区 实体类
 */
@Data
@TableName("t_mall_home_group_put_up_area")
public class MallHomeGroupPutUpArea {
    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("home_grep_area_no")
    private String homeGrepAreaNo;

    @TableField("no")
    private String no;

    @TableField("title")
    private String title;

    @TableField("top3_tag")
    private Integer top3Tag;

    @TableField("goods_setting_type")
    private String goodsSettingType;

    @TableField("rule_json")
    private String ruleJson;

    @TableField("is_sale_num")
    private Integer isSaleNum;

    @TableField("version")
    @Version
    private Integer version;

    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @TableField(value = "update_time", update = "now()")
    private LocalDateTime updateTime;

    @Data
    public static class ImportRuleDTO {

        private String type;

        private Integer day;

        private Integer num;
    }


    public ImportRuleDTO getImportRule() {
        return JSONObject.parseObject(ruleJson, ImportRuleDTO.class);
    }


    @AllArgsConstructor
    @Getter
    public enum Enums {

        MANUAL, ONLY_GOODS, IMPORT_RULE, NEW_LINE_SALE_NUM, N_DAY_SALE_NUM;

    }

    public static final Map<String, String> ENUM_MAP = new HashMap<>();

    static {
        ENUM_MAP.put(Enums.MANUAL.toString(), "手动配置");
        ENUM_MAP.put(Enums.ONLY_GOODS.toString(), "指定唯一商品");
        ENUM_MAP.put(Enums.IMPORT_RULE.toString(), "规则引用");
        ENUM_MAP.put(Enums.NEW_LINE_SALE_NUM.toString(), "上新n天后销量前几的商品");
        ENUM_MAP.put(Enums.N_DAY_SALE_NUM.toString(), "n天内销量最多的n件商品");
    }
}
